deployment: Add an API to get relative origin path
authorColin Walters <walters@verbum.org>
Tue, 10 Mar 2015 13:07:12 +0000 (09:07 -0400)
committerColin Walters <walters@verbum.org>
Tue, 10 Mar 2015 14:47:47 +0000 (10:47 -0400)
This will be used for fd-relative cleanups.

src/libostree/ostree-deployment.c
src/libostree/ostree-deployment.h

index 4533715c2fa2c9130a634db2c87036c5797082b6..0f98c59807da5595fe2eea79f38e1cb7aafac76a 100644 (file)
@@ -252,3 +252,22 @@ ostree_deployment_new (int    index,
   self->bootserial = bootserial;
   return self;
 }
+
+/**
+ * ostree_deployment_get_origin_relpath:
+ * @self: A deployment
+ *
+ * Note this function only returns a *relative* path - if you want to
+ * access, it, you must either use fd-relative api such as openat(),
+ * or concatenate it with the full ostree_sysroot_get_path().
+ *
+ * Returns: (transfer full): Path to deployment root directory, relative to sysroot
+ */
+char *
+ostree_deployment_get_origin_relpath (OstreeDeployment *self)
+{
+  return g_strdup_printf ("ostree/deploy/%s/deploy/%s.%d.origin",
+                          ostree_deployment_get_osname (self),
+                          ostree_deployment_get_csum (self),
+                          ostree_deployment_get_deployserial (self));
+}
index 0dbe6f1b2b2ec36068940fceff8332e7a7eaaec2..dc28d63ab101bd687b16edcf037153e8564f227b 100644 (file)
@@ -58,5 +58,6 @@ void ostree_deployment_set_origin (OstreeDeployment *self, GKeyFile *origin);
 
 OstreeDeployment *ostree_deployment_clone (OstreeDeployment *self);
 
+char *ostree_deployment_get_origin_relpath (OstreeDeployment *self);
 
 G_END_DECLS